package com.wangyonghao.harmonyocrs;

import com.wangyonghao.harmonyocrs.slice.*;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;

public class MainAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(MainAbilitySlice.class.getName());
        addActionRoute("historyAbilitySlice", HistoryAbilitySlice.class.getName());
        addActionRoute("historyDetailAbilitySlice", HistoryDetailAbilitySlice.class.getName());
//        addActionRoute("cameraAbilitySlice", CameraAbilitySlice.class.getName());
        addActionRoute("mainAbilitySlice", MainAbilitySlice.class.getName());
        //请求设备的权限:相机,录音,位置,存储,网络
        String[] permissions = {"ohos.permission.CAMERA"
                , "ohos.permission.MICROPHONE"
                , "ohos.permission.LOCATION"
                , "ohos.permission.READ_MEDIA"
                , "ohos.permission.WRITE_MEDIA"
                , "ohos.permission.INTERNET"
                , "ohos.permission.READ_USER_STORAGE"
                , "ohos.permission.WRITE_USER_STORAGE"};
        requestPermissionsFromUser(permissions, 0);
    }

//    //检查授权结果,若用户不授权,则退出应用
//    @Override
//    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
//        if (permissions == null || permissions.length == 0 || grantResults == null || grantResults.length == 0) {
//            return;
//        }
//        for (int grantResult : grantResults) {
//            if (grantResult != IBundleManager.PERMISSION_GRANTED) {
//                terminateAbility();
//                break;
//            }
//        }
//    }
}
